package com.chapter10.static_;

public class ChildGame {
    public static void main(String[] args) {
        Child child1 = new Child("张三");
        child1.join();
        Child child2 = new Child("李四");
        child2.join();
        Child child3 = new Child("王五");
        child3.join();

        //count变量会被创建此类的所有对象共享
        System.out.println("共有" + child1.count + "个孩子加入了游戏");
        new AA("mm").BB();
    }
}

class Child {
    private String name;
    //创建一个类变量(静态变量) static 静态
    //该变量的特点就是会被此类所有对象共享
    public static int count = 0;

    public Child(String name) {
        this.name = name;
    }

    public static void join() {
        System.out.println( "加入了游戏...");
        count++;
    }
}
class AA extends Child{
    public AA(String name) {
        super(name);
    }
    public void AA(){
        count = 10;
    }
    public static void BB(){
        join();
    }
}
